<template>
  <a-config-provider :locale="locale">
    <div id="app">
      <a-spin :spinning="loading" size="large">
        <router-view />
      </a-spin>
    </div>
  </a-config-provider>
</template>
<script>
  import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
  import enquireScreen from '@/utils/device'
  import { mapState } from 'vuex'

  export default {
    data () {
      return {
        locale: zhCN,
      }
    },
    computed: {
      ...mapState({
        loading: state => state.spin.loading
      })
    },
    created () {
      let that = this
      enquireScreen(deviceType => {
        // tablet
        if (deviceType === 0) {
          that.$store.commit('TOGGLE_DEVICE', 'mobile')
          that.$store.dispatch('setSidebar', false)
        }
        // mobile
        else if (deviceType === 1) {
          that.$store.commit('TOGGLE_DEVICE', 'mobile')
          that.$store.dispatch('setSidebar', false)
        }
        else {
          that.$store.commit('TOGGLE_DEVICE', 'desktop')
          that.$store.dispatch('setSidebar', true)
        }

      })
    }
  }
</script>
<style>
  #app {
    height: 100%;
  }

  .ant-spin-nested-loading {
    width: 100%;
    height: 100%;
  }

  .ant-spin-container {
    width: 100%;
    height: 100%;
  }
</style>
